import axios from 'axios';

const api = axios.create({
  baseURL: 'http://localhost:3000/api',
  headers: {
    'Content-Type': 'application/json'
  }
});

export const photoApi = {
  async getAllPhotos() {
    const response = await api.get('/photos');
    return response.data;
  },

  async uploadPhoto(file: File, title: string, description: string) {
    const formData = new FormData();
    formData.append('photo', file);
    formData.append('title', title);
    formData.append('description', description);

    const response = await api.post('/photos', formData, {
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    });
    return response.data;
  },

  async deletePhoto(id: number) {
    await api.delete(`/photos/${id}`);
  }
};